﻿/*******************************************************************************
* Copyright (C) 2006-2011 newportcn
* @author Jiyuan
*******************************************************************************/
function formulaBulid(str) {
    //alert(str);
    var img_reg = /<img.+?>/ig; //匹配符合img标签
    var img_arr = str.match(img_reg); //得到所有img标签
    //        alert(img_arr);
    if (img_arr != undefined) {
        for (var i = 0; i < img_arr.length; i++) {
            str = str.replace("b.png", "_1.png");
        }
    }
    editor.html(str);
    editor.appendHtml("");
    editor.focus();
}
KindEditor.plugin('cformula', function (K) {
    var self = this, name = 'cformula', lang = self.lang(name + '.');

    self.clickToolbar(name, function () {
        self.focus();
        var width = 798;
        var height = 447;
        var left, top;
        left = (window.screen.availWidth - width) / 2;
        top = (window.screen.availHeight - height) / 2;
        var per = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top + ",toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
        //        var scriptObj = window.frames[0].document.createElement("script");
        //        scriptObj.src = "/Scripts/Formula/MathML_pro.js";
        //        scriptObj.type = "text/javascript";
        //        window.frames[0].document.body.appendChild(scriptObj);
        window.open('/Formula/NewFormulaEditer', '公式编辑器', per);
        
        //        self.focus();
        //        var x = screen.availWidth;
        //        var y = screen.availHeight;
        //        x = (x - 600) / 2;
        //        y = (y - 300) / 4;
        //        var scriptObj = window.frames[0].document.createElement("script");
        //        scriptObj.src = "/Scripts/Formula/MathML_pro.js";
        //        scriptObj.type = "text/javascript";
        //        window.frames[0].document.body.appendChild(scriptObj);
        //        window.open('/Formula/NewFormulaEditer', '公式编辑器', 'height=800, width=1200,top=' + y + ', left=' + x + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
    });
});
